package com.ygsoft.nio.fileserver;

import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.*;

public class SocketChannelQueue {
	
	private LinkedList<SocketChannel> list = new LinkedList<SocketChannel>();
	private Selector readSelector;
	
	SocketChannelQueue() {
	}
	
	public void setReadSelector(Selector readSelector) {
		this.readSelector = readSelector;
	}
	
	public void addLast(SocketChannel channel) {
		list.addLast(channel);
		readSelector.wakeup();
	}
	
	public SocketChannel getFirst() {
		if (list.size() == 0) return null;
		
		return list.removeFirst();
	}
	
}
